import React, { Component } from 'react'

import axios from 'axios'

export default class App extends Component {
    // 请求数据
    getStudentData = ()=>{
        axios.get('http://localhost:3000/api1/students').then(response=>{console.log("成功",response.data)},error=>{ console.log("失败",error) })
    }

    // 请求数据
    getCarData = ()=>{
        axios.get('http://localhost:3000/api2/car').then(response=>{console.log("成功",response.data)},error=>{ console.log("失败",error) })
    }

    render() {
        return (
            <div>
                <button onClick={ this.getStudentData }>点击请求学生数据</button>
                <button onClick={ this.getCarData }>点击请求汽车数据</button>
            </div>
        )
    }
}
